package com.sinaapp.mspring.beetl.func;

import java.util.Date;

import org.beetl.core.Context;
import org.beetl.core.Function;

/**
 * 日期相减，返回年龄
 * 
 * @author binchao
 *
 */
public class DateSub implements Function {

	@Override
	public Object call(Object[] paras, Context ctx) {

		Date d1 = (Date) paras[0];
		Date d2 = (Date) paras[1];
		
		long days = (d1.getTime() - d2.getTime())/(1000*60*60*24);
		
		return (int)days/365;
	}

}
